n = eval(input())
list1 = list(map(int, input().split()))
list2 = [list1[0]]
max_list = [list1[0]]
for i in range(1, n):
    if len(list2) == 0:
        list2.append(list1[i-1])
    if list1[i-1] < list1[i]:
        list2.append(list1[i])
        if len(max_list) < len(list2):
            max_list = list2.copy()
    else:
        list2.clear()

for i in range(len(max_list)):
    if i != len(max_list)-1:
        print(f'{max_list[i]}', end=' ')
    else:
        print(f'{max_list[i]}')
